<?php

namespace App\Exports\Plane;

use App\Models\Plane\Airports\Airport;
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\FromCollection;

class AirportsExport implements FromCollection
{
    /**
     * @return Collection
     */
    public function collection()
    {
        $airports = Airport::get();


        $res = $airports->map(function ($airport) {
            return [
                'code'       => $airport['code'],
                'name'       => $airport['name'],
                'short_name' => $airport['short_name'],
                'name_uy'    => $airport['name_uy'],
                'letter_uy'  => "",
            ];
        })->toArray();

        $head = [
            "机场码",
            "机场名称(不翻译)",
            "机场简称",
            "机场简称翻译",
            "机场简称首字母翻译",
        ];
        array_unshift($res, $head);
        return collect($res);
    }
}
